<?php TPL::output('global/header.tpl.htm'); ?>
<style>
	.bd_weixin_popup .bd_weixin_popup_main {
		padding: 10px 10px;
	}
	.common-head em{font-style: italic}
	.common-head li {
		margin-left:50px;
	}
	#img1{
		position: absolute;
		top:23.4px;
		left:172.7px;
		z-index:1;
		width:386px;
		height:685px;
	}
	.mod-link{
		position: absolute;
		margin-top:444.8px;
		background-image: url(static/admin/img/Artboard.png);
		z-index: 2
	}
	#inviteimg{
		background-color: rgb(190,216,255);
		position: absolute;
		height:600px;
		width:732px;
	}
	#copyimg{
		border: 1px solid #cccccc;
		cursor: pointer;
		height: 43.2px;
		display: block;
		width: 240.1px;
		text-align: center;
		line-height: 30px;
		border-radius: 8px;
		padding-top:5px;
		background-color: white;
		font-size: 18px;
		color: #5F9CEC;
	}
	#registerurl{
		border: 1px solid #cccccc;
		cursor: pointer;
		height:70px;
		width:480px;
		border-radius: 8px;
		padding-top:15px;
		text-align: center;
		background-color: white;
		display:inline-block;
		font-size: 18px;
		color: #5F9CEC;
		resize:none;
	}
	#registerurlbutton{
		border: 1px solid #cccccc;
		cursor: pointer;
		height:70px;
		width:185px;
		border-radius: 8px;
		padding-top:20px;
		text-align: center;
		background-color: white;
		display:inline-block;
		float:right;
		font-size: 24px;
		color: #5F9CEC;
	}
	#income{
		width:473px;
		padding-top: 8px;
		height:142px;
		background-image: url(static/admin/img/Group.png);
		z-index: 3;
	}
	.invite-num{
		color:#FF6D6D;
		padding-top:30px;
		font-size: 36px;
	}
	.mod-table-foot img{
		width:11px;
		height: 13px;
	}
	#previous{
		margin-left:15px;
	}
	#next{
		margin-right:15px;
	}
	.table-striped>tbody>tr:nth-child(odd)>td, .table-striped>tbody>tr:nth-child(odd)>th{
		background: #e7effa;
	}
	#currentsort{
		border: 1px solid #cccccc;
		cursor: pointer;
		height:81px;
		width:213px;
		border-radius: 8px;
		padding-top:25px;
		padding-left: 10px;
		background-color: white;
		display:inline-block;
		font-size: 20px;
		margin-bottom: 8px;
		color: #666666;
	}
	#allsort{
		border: 1px solid #cccccc;
		cursor: pointer;
		height:44px;
		line-height: 44px;
		width:213px;
		border-radius: 8px;
		text-align: center;
		background-color: white;
		display:inline-block;
		font-size: 18px;
		color: #5F9CEC;
	}
</style>
<div class="aw-container-wrap">
	<div class="container">
		<div class="row">
			<div class="aw-content-wrap clearfix">
				<div class="col-sm-12 col-md-9 aw-main-content">
					<div class="aw-mod aw-mod-invite-friend">
						<div class="mod-body">
							<div id="inviteimg">
								<img id="img1"  src="<?php echo $this->poster_url;?>"/>
							</div>
							<div class="mod-link">
                      			<div style="padding:122px 246px 0 246px;">
									<span id="copyimg" onclick="ButtonClick()" data-clipboard-target="#inviteimg">点击复制个人邀请海报</span>
								</div>
								<div style="padding:40px 18px 0 18px;">
									<textarea id="registerurl" rows="2" readonly="readonly"><?php _e($this->invitation_code ? base_url().'/?/account/register/invitation_code-'.$this->invitation_code : base_url().'/?/account/register/'); ?></textarea>
									<span id="registerurlbutton" onclick="$('#registerurl').select();document.execCommand('copy',false,null); AWS.alert('复制成功～');">复制</span>
								</div>
								<div style="margin:25px 12px 0 12px;width:700px;" >
									<div style="display: inline-block;" id="income">
										<div style="display: inline-block;width:215px;height:132px;text-align: center;">
											<p class="invite-num"><?php echo $this->invitation_num;?></p>
											<p style="margin:20px 0 0 0;">已邀请好友</p>
											<p>（人）</p>
										</div>
										<div  style="display: inline-block ;width:243px;height:132px;text-align: center;">
											<p class="invite-num"><?php if($this->invitation_sum_yoyow){ ?><?php echo $this->invitation_sum_yoyow;?><?php }else{?><?php echo 0;?><?php }?></p>
											<p style="margin:20px 0 0 0;">预期总收益</p>
											<p>（YOYOW）</p>
										</div>
									</div>
									<div style="display: inline-block ;width:140px;height:140px;margin:0 0 0 15px;">
										<!--<p id="currentsort" >当前排名：<span style="color:#FF6D6D;font-size: 24px;margin-left:20px;"><?php if($this->sort){ echo $this->sort;}else{echo '- -';}?></span></p>
										<a id="allsort" href="invitation/ajax/invitation_sort/">点击查看全部排名</a>-->
									</div>
								</div>
								<div style="margin:23px 18px 0 18px;background-color: white;">
									<form action="invitation/ajax/invitation_list2" method="post" onsubmit="return false;">
										<table class="table table-striped table-list">
											<thead>
											<tr>
												<th width="10%">序号</th>
												<th width="14%">用户名</th>
												<th width="17%">时间</th>
												<th width="22%">奖励</th>
												<th width="42%">备注</th>
											</tr>
											</thead>
											<tbody id="invitation_list2">

											</tbody>

										</table>
									</form>
									<div class="mod-table-foot" style="margin-left:580px;display: inline-block;">
										<a id="invitation_list_last" data-page="0"  onclick="load_invite_view(G_BASE_URL + '/invitation/ajax/invitation_list2/', $('#invitation_list_last'),  $('#invitation_list2'));"><img src="static/admin/img/previous_non.png"/></a>
										<span id="previous">2</span><span id="next">/<?php echo $this->total_page;?></span>
										<a id="invitation_list_next" data-page="2"  onclick="load_invite_view(G_BASE_URL + '/invitation/ajax/invitation_list2/', $('#invitation_list_next'),  $('#invitation_list2'));"><img src="static/admin/img/next_non.png"/></a>
									</div>
									<input type="hidden" id="total_page" value="<?php echo $this->total_page;?>"/>
								</div>
								<div style="padding:23px 18px 81px 18px;">
									<div style="background-color: #FFF;border-radius: 5px;padding:23px 18px 81px 18px;">
										<?php echo get_setting('invitation_code_remark')?>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>

				<!-- 侧边栏 -->
				<div class="col-sm-12 col-md-3 aw-side-bar">
					<?php TPL::output('block/sidebar_menu.tpl.htm'); ?>
				</div>
				<!-- end 侧边栏 -->
			</div>
		</div>
	</div>
</div>
<script type="text/javascript" src="<?php echo G_STATIC_URL; ?>/js/fileupload.js"></script>
<script type="text/javascript">
    $(document).ready(function ()
    {
        function setCookie(name,value,time) {
            var strsec = getsec(time);
            var exp = new Date();
            exp.setTime(exp.getTime() - strsec*1);
            document.cookie = name + "="+ value + ";expires=" + exp.toGMTString()+";path=/";
        }

        function getsec(str) {
            var str1=str.substring(1,str.length)*1;
            var str2=str.substring(0,1);
            if (str2=="s") {
                return str1*1000;
            } else if (str2=="h") {
                return str1*60*60*1000;
            } else if (str2=="d") {
                return str1*24*60*60*1000;
            }
        }

        function getCookie(name) {
            var strCookie = document.cookie;
            var arr = strCookie.split(';');
            for (var i = 0; i < arr.length; i++) {
                var t = arr[i].split("=");
                if($.trim(t[0]) == name) {
                    return t[1];
                }
            };
            return null;
        }

        var user_id= '<?php echo $this->user_id ?>';
        var message = getCookie("message_"+user_id);

        if(message){alert(decodeURIComponent(message));
            setCookie("message_"+user_id, "", 's86400');
        }

    })

</script>

<script src="https://cdn.jsdelivr.net/clipboard.js/1.5.12/clipboard.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    var share_content = '<?php echo get_setting("share_content");?>';
    var share_url = "<?php _e($this->invitation_code?base_url().'/?/account/register/invitation_code-'.$this->invitation_code:base_url().'/?/account/register/'); ?>";
    $('#registerurl').text(share_content+share_url);
	//AWS.load_list_view(G_BASE_URL + '/invitation/ajax/invitation_list2/', $('#invitation_more'),  $('#invitation_list2'));
    $('#invitation_list_last').click();
});
$('#copyimg').mouseover(function(){
	$(this).css('background-color','#5F9CEC')
	$(this).css('color','white');
});
$('#copyimg').mouseleave(function(){
    $(this).css('background-color','white')
    $(this).css('color','#5F9CEC');
});
$('#registerurlbutton').mouseover(function(){
    $(this).css('background-color','#5F9CEC')
    $(this).css('color','white');
});
$('#registerurlbutton').mouseleave(function(){
    $(this).css('background-color','white')
    $(this).css('color','#5F9CEC');
});

function ButtonClick(){
    var clipboard = new Clipboard('#copyimg', {
        target: function() {
            return document.querySelector('#inviteimg');
        }

    });
    // var clipboard = new Clipboard( '#copyimg' );
    //
    // clipboard.on('success',function(e){
    //     AWS.alert("复制成功");
    //     //e.clearSelection();
    //     //clipboard.destroy()
    // })
    // clipboard.on('error', function(e) {
    //     AWS.alert('请选择“拷贝”进行复制!');
    //     clipboard.destroy()
    // });

}
var first_load =true;
// 加载更多
function load_invite_view(url, selector, container, topage, start_page, callback)
{
    if (!selector.attr('id'))
    {
        return false;
    }

    if (!start_page)
    {
        start_page = 0
    }

    // 把页数绑定在元素上面
    if (selector.attr('data-page') == undefined)
    {
        selector.attr('data-page', start_page);
    }
    else
    {
        selector.attr('data-page', parseInt(selector.attr('data-page')));
    }
        $.get(url + '?page=' + selector.attr('data-page'), function (result)
        {
            if ($.trim(result) != '')
            {
                first_load =false;
                container.html(result);
                // 页数增加1
                if(selector.attr('data-page') != 0 && selector.attr('id')=='invitation_list_last'){
					$('#previous').html(parseInt($('#previous').html())-1);
                    selector.attr('data-page', parseInt(selector.attr('data-page')) -1);
                    $('#invitation_list_next').attr('data-page', parseInt($('#invitation_list_next').attr('data-page')) -1);
                }else if(selector.attr('data-page') != 0 && selector.attr('id')=='invitation_list_next'){
                    $('#previous').html(parseInt($('#previous').html())+1);
                    selector.attr('data-page', parseInt(selector.attr('data-page')) + 1);
                    $('#invitation_list_last').attr('data-page', parseInt($('#invitation_list_last').attr('data-page')) +1);
                }else{
                    $('#previous').html(parseInt($('#previous').html())-1);
                    selector.attr('data-page', parseInt(selector.attr('data-page')) -1);
                    $('#invitation_list_next').attr('data-page', parseInt($('#invitation_list_next').attr('data-page')) -1);
				}

				if($('#invitation_list_last').attr('data-page')==-1){
                    $('#invitation_list_last').find('img').attr('src','static/admin/img/previous_non.png');
				}else{
                    $('#invitation_list_last').find('img').attr('src','static/admin/img/previous_def.png');
				}
                if($('#invitation_list_next').attr('data-page')==$('#total_page').val()){
                    $('#invitation_list_next').find('img').attr('src','static/admin/img/next_non.png');
                }else{
                    $('#invitation_list_next').find('img').attr('src','static/admin/img/next_def.png');
                }
                $('#invitation_list_last').mouseover(function(){
                    if($('#invitation_list_last').attr('data-page')!=-1) {
                        $('#invitation_list_last').find('img').attr('src','static/admin/img/previous_click.png');
                    }
				});
                $('#invitation_list_last').mouseleave(function(){
                    if($('#invitation_list_last').attr('data-page')==-1){
                        $('#invitation_list_last').find('img').attr('src','static/admin/img/previous_non.png');
                    }else{
                        $('#invitation_list_last').find('img').attr('src','static/admin/img/previous_def.png');
                    }
                });
                $('#invitation_list_next').mouseover(function(){
                    if($('#invitation_list_next').attr('data-page')!=$('#total_page').val()) {
                        $('#invitation_list_next').find('img').attr('src','static/admin/img/next_click.png');
                    }
                });
                $('#invitation_list_next').mouseleave(function(){
                    if($('#invitation_list_next').attr('data-page')==$('#total_page').val()){
                        $('#invitation_list_next').find('img').attr('src','static/admin/img/next_non.png');
                    }else{
                        $('#invitation_list_next').find('img').attr('src','static/admin/img/next_def.png');
                    }
                });
            }else{
                if(first_load == true){
                    first_load =false;
                    $('#previous').html(parseInt($('#previous').html())-2);
                }
            }
            if (callback != null)
            {
                callback();
            }
        });

        return false;

}
window._bd_share_config={
    "common":{
        bdText : '<?php echo get_setting("share_content");?>',
        bdDesc : '<?php echo get_setting("share_title");?>',
        bdUrl : G_BASE_URL + $("#invcode").val(),
        bdPic : '<?php echo get_js_url($this->pic_url); ?>'
        // bdPic : '<?php echo G_STATIC_URL; ?>/common/pc-poster.png'
	},
    "share":[{
        bdSize : '24'
	}]
};
with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
</script>

<?php TPL::output('global/footer.tpl.htm'); ?>